/*
 * Created by JFormDesigner on Sun Jun 30 14:23:39 CST 2024
 */

package scct.hys.ui;

import scct.hys.dao.CinemaDao;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author 26984
 */
public class DlgCinemaAdd extends JDialog {
        int id;
    public DlgCinemaAdd(Window owner) {
        super(owner);
        initComponents();
        this.id=id;
    }

    private void btnAdd(ActionEvent e) {
        // TODO add your code here

        String name=txtCinemaName.getText();
        String address=txtAddress.getText();
        String totalseats=txtTotalseats.getText();
        CinemaDao cinemaDao=new CinemaDao();
        if (cinemaDao.addCinema(name,address,totalseats)){
            JOptionPane.showMessageDialog(this,"添加成功");
        }
        this.dispose();
    }


    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        // Generated using JFormDesigner Evaluation license - 韩月生
        label1 = new JLabel();
        txtCinemaName = new JTextField();
        label2 = new JLabel();
        txtAddress = new JTextField();
        label3 = new JLabel();
        btnAdd = new JButton();
        btnCancel = new JButton();
        txtTotalseats = new JTextField();

        //======== this ========
        setTitle("\u6dfb\u52a0\u5f71\u9662");
        var contentPane = getContentPane();
        contentPane.setLayout(null);

        //---- label1 ----
        label1.setText("\u5f71\u9662\u540d\u79f0");
        contentPane.add(label1);
        label1.setBounds(new Rectangle(new Point(25, 45), label1.getPreferredSize()));
        contentPane.add(txtCinemaName);
        txtCinemaName.setBounds(110, 38, 95, 30);

        //---- label2 ----
        label2.setText("\u5f71\u9662\u5730\u5740");
        contentPane.add(label2);
        label2.setBounds(25, 96, 48, 17);
        contentPane.add(txtAddress);
        txtAddress.setBounds(110, 89, 185, 30);

        //---- label3 ----
        label3.setText("\u603b\u5ea7\u4f4d\u6570");
        contentPane.add(label3);
        label3.setBounds(25, 147, 48, 17);

        //---- btnAdd ----
        btnAdd.setText("\u6dfb\u52a0");
        btnAdd.addActionListener(e -> btnAdd(e));
        contentPane.add(btnAdd);
        btnAdd.setBounds(new Rectangle(new Point(65, 200), btnAdd.getPreferredSize()));

        //---- btnCancel ----
        btnCancel.setText("\u53d6\u6d88");
        contentPane.add(btnCancel);
        btnCancel.setBounds(new Rectangle(new Point(250, 200), btnCancel.getPreferredSize()));
        contentPane.add(txtTotalseats);
        txtTotalseats.setBounds(110, 140, 185, txtTotalseats.getPreferredSize().height);

        {
            // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < contentPane.getComponentCount(); i++) {
                Rectangle bounds = contentPane.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = contentPane.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            contentPane.setMinimumSize(preferredSize);
            contentPane.setPreferredSize(preferredSize);
        }
        setSize(400, 300);
        setLocationRelativeTo(null);
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    // Generated using JFormDesigner Evaluation license - 韩月生
    private JLabel label1;
    private JTextField txtCinemaName;
    private JLabel label2;
    private JTextField txtAddress;
    private JLabel label3;
    private JButton btnAdd;
    private JButton btnCancel;
    private JTextField txtTotalseats;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
